package com.chx.mapper;

import com.chx.annotation.AutoFill;
import com.chx.dto.SupplierPageQueryDto;
import com.chx.entity.Suppliers;
import com.chx.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author cp-月入过万
 * @Date 2025/5/30
 */
@Mapper
public interface SupplierMapper {
    @Insert("insert into suppliers (supplier_name,contact_person,phone,address,email,description,create_time,update_time) " +
            "values " +
            "(#{supplierName},#{contactPerson},#{phone},#{address},#{email},#{description},#{createTime},#{updateTime})")
    @AutoFill(OperationType.INSERT)
    void insert(Suppliers suppliers);

    @AutoFill(OperationType.UPDATE)
    void update(Suppliers suppliers);

    @Delete("delete from suppliers where supplier_id = #{id}")
    void delete(Long id);

    @Select("select * from suppliers where supplier_id = #{id}")
    Suppliers getById(Long id);

    Page<Suppliers> pageQuery(SupplierPageQueryDto supplierPageQueryDto);

    @Select("select * from suppliers")
    List<Suppliers> getAllSuppliers();
}
